package com.stylefeng.guns.modular.system.warpper;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.DateUtil;

public class MkdataWarpper extends BaseControllerWarpper{

	public MkdataWarpper(Object list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
		map.put("gTimePre",StringUtils.substringBefore(map.get("gTimePre").toString(), " "));
		map.put("gTime", StringUtils.substringBefore(map.get("gTime").toString(), " "));
		DecimalFormat df = new DecimalFormat("0.00");
		map.put("gLtsz", df.format(Math.abs(((Double)map.get("gLtsz") / 100000000))));
		
		double gZjbl = ((Double)map.get("gZjbl"));
		map.put("gZjbl", (gZjbl >0 ? "<font color='red'><b>"+gZjbl+"</b></font>" : "<font color='green'><b>"+gZjbl+"</b></font>"));
		double gZj = ((Double)map.get("gZj"));
		map.put("gZj", (gZj >0 ? "<font color='red'><b>"+gZj+"</b></font>" : "<font color='green'><b>"+gZj+"</b></font>"));
		double gJqZdf = ((Double)map.get("gJqZdf"));
		map.put("gJqZdf", (gJqZdf >0 ? "<font color='red'><b>"+gJqZdf+"</b></font>" : "<font color='green'><b>"+gJqZdf+"</b></font>"));
		
		int gIsYgsmNum = ((Integer)map.get("gIsYgsmNum"));
		map.put("gIsYgsmNum", (gIsYgsmNum >0 ? "<font color='red'><b>"+gIsYgsmNum+"</b></font>" : "<font color='green'><b>"+gIsYgsmNum+"</b></font>"));
		int gIsGrsmNum = ((Integer)map.get("gIsGrsmNum"));
		map.put("gIsGrsmNum", (gIsGrsmNum >0 ? "<font color='red'><b>"+gIsGrsmNum+"</b></font>" : "<font color='green'><b>"+gIsGrsmNum+"</b></font>"));
		int gIsQfillNum = ((Integer)map.get("gIsQfillNum"));
		map.put("gIsQfillNum", (gIsQfillNum >0 ? "<font color='red'><b>"+gIsQfillNum+"</b></font>" : "<font color='green'><b>"+gIsQfillNum+"</b></font>"));
		int gIsJjNum = ((Integer)map.get("gIsJjNum"));
		map.put("gIsJjNum", (gIsJjNum >0 ? "<font color='red'><b>"+gIsJjNum+"</b></font>" : "<font color='green'><b>"+gIsJjNum+"</b></font>"));
		int gIsGjdNum = ((Integer)map.get("gIsGjdNum"));
		map.put("gIsGjdNum", (gIsGjdNum >0 ? "<font color='red'><b>"+gIsGjdNum+"</b></font>" : "<font color='green'><b>"+gIsGjdNum+"</b></font>"));
		
		int gIsQynjNum = ((Integer)map.get("gIsQynjNum"));
		map.put("gIsQynjNum", (gIsQynjNum >0 ? "<font color='red'><b>"+gIsQynjNum+"</b></font>" : "<font color='green'><b>"+gIsQynjNum+"</b></font>"));
		
		Long gMkType = ((Long)map.get("gMkType"));
		String font = "";
		if(gMkType == 1l){
			font = "<font color='red'><b>MACD底部背离</b></font>";
		}else if(gMkType == 2l){
			font = "<font color='red'><b>KDJ金叉</b></font>";
		}else{
			font = "<font color='red'><b>MACD/KDJ</b></font>";
		}
		map.put("gMkType", font);
		
		Date date = ((Date)map.get("gDate"));
		map.put("gDate", DateUtil.format(date, "yyyy-MM-dd"));
    }
    
    
}
